package com.ruoyi.web.controller.module.employee;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.employee.domain.EmployeeGift;
import com.ruoyi.employee.service.IEmployeeGiftService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 店员关联收到礼物信息
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/employee/gift")
public class EmployeeGiftController extends BaseController
{
    @Autowired
    private IEmployeeGiftService employeeGiftService;

    /**
     * 获取店员关联收到礼物列表
     */
    @PostMapping("/employeeGiftList")
    public TableDataInfo list(@RequestBody EmployeeGift employeeGift, HttpServletRequest request)
    {
        String shopId = request.getHeader("ShopId"); // 店铺id
        if(shopId != null && !shopId.equals("")){
            employeeGift.setShopId(shopId);
        }
        startPageByPost();
        List<EmployeeGift> list = employeeGiftService.selectEmployeeGiftList(employeeGift);
        return getDataTable(list);
    }


    /**
     * 删除店员关联收到礼物
     */
    @PreAuthorize("@ss.hasPermi('employee:user:remove')")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(employeeGiftService.deleteEmployeeGiftByIds(ids));
    }

}
